<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pat="http://java.sun.com/jsf/composite/patient">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="patient" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <h:panelGrid columns="1" >
            <p:selectBooleanCheckbox value="#{patientController.reportKeyWord.additionalDetails}" 
                                     itemLabel="Serch Only Registed Patient" >
                <f:ajax execute="@this" render="acPt" />
            </p:selectBooleanCheckbox>
            <p:autoComplete widgetVar="aPt" id="acPt" forceSelection="true" 
                            value="#{cc.attrs.patient}" converter="patientConverter"
                            completeMethod="#{patientController.completePatientByNameOrCode}" 
                            var="apt" itemLabel="#{apt.person.nameWithTitle}" 
                            itemValue="#{apt}" size="30"  style="width: 400px;" >
                <p:column headerText="Name">
                    <h:outputLabel value="#{apt.person.nameWithTitle}" />
                </p:column>
                <p:column headerText="Age">
                    <h:outputLabel value="#{apt.age}" />
                </p:column>
                <p:column headerText="NIC">
                    <h:outputLabel value="#{apt.person.nic}"/>
                </p:column>
                <p:column headerText="Code">
                    <h:outputLabel value="#{apt.code}" />
                </p:column>
                <p:column headerText="PHN">
                    <h:outputLabel value="#{apt.phn}"/>
                </p:column>
                <p:column headerText="Sex">
                    <h:outputLabel value="#{apt.person.sex}" />
                </p:column>
                <p:column headerText="Address">
                    <h:outputLabel value="#{apt.person.address}" />
                </p:column>
                <p:column headerText="Date of Birth">
                    <h:outputLabel value="#{apt.person.dob}" >
                        <f:convertDateTime pattern="dd MMMM yyyy"/>
                    </h:outputLabel>
                </p:column>
                <p:ajax event="itemSelect" process="acPt" update="panSearch"/>
            </p:autoComplete>   

            <h:panelGroup id="panSearch">
                <pat:searchPatientDetail patient="#{cc.attrs.patient}"/>
            </h:panelGroup>
        </h:panelGrid>
    </cc:implementation>
</html>